﻿<ctrl:GuiControl x:Class="CannedBytes.CommandLineGui.UI.Controls.GroupOptionsContainerControl" x:ClassModifier="internal"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ctrl="clr-namespace:CannedBytes.CommandLineGui.UI.Controls"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="700"
             ToolTip="{Binding Description, Mode=OneTime}">

    <Grid Name="LayoutGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <ctrl:Help DataContext="{Binding Path=HelpInfo, Mode=OneTime}"
                   Grid.Column="2" Height="36"
                   HorizontalAlignment="Right" VerticalAlignment="Top"/>

        <Expander Grid.ColumnSpan="2"
                  IsExpanded="{Binding IsExpanded, Mode=TwoWay}">
            <ItemsControl Name="GlobalOptions"
                          ItemsSource="{Binding Path=ValueBindings, Mode=OneTime}"
                          ItemTemplateSelector="{StaticResource ControlTemplateSelector}" />
        </Expander>

        <TabControl Name="RootGroups" Grid.Row="1" Grid.ColumnSpan="3"
                    ItemsSource="{Binding Path=GroupBindings, Mode=OneTime}"
                    SelectedItem="{Binding SelectedOption, Mode=TwoWay}"
                    ItemTemplateSelector="{StaticResource ControlTemplateSelector}"
                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

            <TabControl.ItemContainerStyle>
                <Style TargetType="TabItem">
                    <Setter Property="Header" Value="{Binding Path=Name, Mode=OneTime}" />
                    <Setter Property="ToolTip" Value="{Binding Path=Description, Mode=OneTime}" />
                    <Setter Property="VerticalAlignment" Value="Stretch" />
                </Style>
            </TabControl.ItemContainerStyle>

            <TabControl.ContentTemplate>
                <DataTemplate>
                    <ScrollViewer VerticalScrollBarVisibility="Auto">
                        <ContentPresenter Content="{Binding}" ContentTemplateSelector="{StaticResource ControlTemplateSelector}" />
                    </ScrollViewer>
                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>

    </Grid>
</ctrl:GuiControl>